package com.incar.chuxing.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.incar.chuxing.R;

/**
 * Created by Michael Pi on 2016/10/19.
 */
public class ToastUtils {
    public static void toast(Context context, int image, String title) {
        View view = LayoutInflater.from(context).inflate(R.layout.toast_layout, null);
        TextView textView = (TextView) view.findViewById(R.id.toast_title);
        ImageView imageView = (ImageView) view.findViewById(R.id.toast_image);
        textView.setText(title);
        imageView.setImageDrawable(context.getResources().getDrawable(image));
        Toast toast = new Toast(context);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, Gravity.CENTER, Gravity.CENTER);
        toast.setView(view);
        toast.show();
    }

}
